<?
/*Created by : G.M.Sundar 
[created : 01/17/2007, 03:52:48 PM]
 Description:

*/

include("../../includes/global_files/tables.inc");
include(DOCINCLUDES."global_files/global_html.inc");
include(DOCINCLUDES."global_files/global_form.inc");//
include(DOCINCLUDES."global_files/global_report.inc");
include(DOCINCLUDES."global_files/tables.inc");
include(DOCINCLUDES."global_files/global_pgsql.inc");
include(DOCINCLUDES."global_files/global_functions.inc");



$page=new cPage;
$page->header_path="../../";

$form=new cForm();
$db=new cDatabase($company_id);
$report=new cReport();
$sql=new pgSql();//


if($_GET)
{
$gsp_id=$_GET['gsp_id'];

}

if($_GET['action']=='delete')
{

$db->query="update $gsp_commercial_details_table set status='del' where gsp_id=$gsp_id";	
$db->runQuery();
header("Location:../reports/report_page.php?report_id=3");
}

if(!$gsp_id)
{
$db->query="Select max(gsp_id) as gsp_id from $gsp_commercial_details_table;";	
$db->runQuery();
$gsp_array=$db->returnArrays();
$gsp_no_val=$gsp_array[0]['gsp_id'];
$gsp_id=$gsp_no_val;
}


$page->doHeaderHtml();


 $db->query="SELECT gspv.buyer_name as \"Buyer Name\" ,
gspv.account_name as \"Exporter Name \" , 
gspv.shipment_mode_name  as \"Shipment Mode\" ,
gspv.port_name as \"Port Name\" , 
gspv.ship_date as \"Date\", 
gspv.remarks as \"Remarks\" ,
gspv.support_documents as \"Support Documents\" ,
gspv.exp_address as \"Address\", 
gspv.city_from as \"City From \" ,
gspv.state_from  as \"State From \" , 
gspv.country_from  as \"Country From  \" , 
gspv.zipcode_from as \"Zip Code\" ,
gspv.address_to as \"Address to \" ,
gspv.city_to as \"City To\" ,
gspv.state_to as \"State To \" , 
gspv.country_to as \" Country To\" ,
gspv.zipcode_to as \"Zip  Code To\",
gspv.book_nos as \"Book Nos\",
gspv.origin_requirements as \"Origin Requirements\",
gspv.ship_status as \"Ship Status\",
gspv.signatory as \"Authorised Signatory\" 
from $gsp_commercial_details_view gspv join $gsp_commercial_details_table gsp on gsp.gsp_id=gspv.gsp_id where
gspv.gsp_id=$gsp_id and gsp.status='act';";
$db->runQuery();
$commercial_array=$db->returnArrays();

 
if($commercial_array)
{
$db->query="SELECT
item_no as
\"Item No\",marks_nos_packages
as \"Mark\",description as \"Description\",origin
as \"Origin\",gross_weight as \"Weight\",nos_invoice_date as \"Nos and Invoice
Date\" from
$gsp_item_details_table where gsp_id=$gsp_id order by item_no;";	
$db->runQuery();
$items_array=$db->returnArrays();
echo "<div align=\"center\">";
echo "<a href=\"gsppdf.php?gsp_id=$gsp_id\">Print Document</a>  || <a
href=\"gsp.php\"> GSP Page </a>  || <a href=\"../reports/report_page.php?report_id=3\"> GSP
Report</a> || <a href=\"gsp.php?gsp_id=$gsp_id&action=edit\"> Edit</a> || <a href=\"gsp_details.php?gsp_id=$gsp_id&action=delete\"> Delete </a>";
echo "<div>";
}
else
{
echo "<div align=\"center\">";
echo "<a href=\"gsp.php\"> GSP Page </a>  || <a href=\"../reports/report_page.php?report_id=3\">GSP Report</a>";
echo "<div> <BR><BR>";
echo "<blink colour=\"red\"> No Data for this GSP - This record may be deleted or not yet created</blink> ";
}

	$report->customization["table_style"]="width:50%; border-style:solid;
border-width:thin; border-collapse:collapse; aligin:left;";
	$report->customization["tr_style"]="border-style:none;
border-width:thin; border-collapse:collapse";
	$report->highlight=true;
	$report->title="GSP Commercial Details";
	$report->data=$commercial_array;
	echo "<div align=\"center\">";
	$report->setNA();
	$report->doHorizontalTable();
	echo "</div>";
	echo "<BR>";
	echo "<BR>";

	$report->customization["table_style"]="width:50%; border-style:solid;
border-width:thin; border-collapse:collapse;";
	$report->customization["tr_style"]="border-style:none;
border-width:thin; border-collapse:collapse";
	$report->highlight=true;
	$report->title="GSP Item Details";
	$report->setNA();
	$report->data=$items_array;
	echo "<div align=\"center\">";
	$report->doHorizontalTable();
	echo "</div>";


?>